(SST) ShlWAPI.pas Version 1.08

Developer Reference
(SST)ShlWAPI PathGetCharType Function
Determines which categories a character would fall in, were it in a path string.
Scope
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas).
Syntax
function PathGetCharType(ch : UCHAR) : UINT;
Parameters
ch [in] The single ANSI (PathGetCharType and PathGetCharTypeA) or Unicode/multi-byte character (PathGetCharTypeW) of which to determine the category/type.
Return Values
Returns one or a combination of the following values:
GCT_INVALID (= $0000) The character is an invalid character in a path.
GCT_LFNCHAR (= $0001) The character may occur in long file names.
GCT_SHORTCHAR (= $0002) The character may occur in short (i.e. DOS 8.3) file names.
GCT_WILD (= $0004) The character is a wildcard character (e.g. "*", "?")
GCT_SEPARATOR (= $0008) The character is a character used to separate the individual components of a path ( i.e. a colon (":") or backslash ("\"))
Remarks
The function does not treat slashes ("/") as separators/delimiters.
Although, the period (".") also has several special meanings in paths, in that it is used to represent the current or parent directory's names and levels in relative paths, in addition to being used to separate the file/folder name from the extension (which, because of the limitatations imposed on the name and extension lengths, is particularly important in DOS, 8.3 names), it is treated as a valid but ordinary character by PathGetCharType.
The function is extremely helpful in parsing path strings and is therefore probably one of the most useful amongst the Shel Lightweight Utility (i.e. ShlWAPI.dll) functions.
Example
PROCEDURE TForm4.TestShlWAPIPathGetCharType(Sender : TObject); VAR chartotest : CHAR; VAR wchartotest : WCHAR; VAR apiretval : UINT; VAR ansicp : UINT; VAR newinfoline : STRING; BEGIN chartotest := #0; wchartotest := #0; apiretval := 0; newinfoline := ''; ansicp := GetACP(); //Determine active ANSI code page for reference purposes only chartotest := ':'; //Colon apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := '.'; //Period apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := '\'; //Backslash apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := '/'; //Slash apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := '*'; //Asterisk apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := '?'; //Quetion mark apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := '~'; //Tilde apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); //Test some Latin characters chartotest := 'A'; // apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := 'b'; // apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); chartotest := 'C'; // apiretval := PathGetCharType(UCHAR(chartotest)); newinfoline := 'PathGetCharType called with ' + AnsiQuotedStr(chartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); //Test some Greek characters using the Unicode version wchartotest := #931; //Greek capital sigma apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); wchartotest := #963; //Greek lower case sigma apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); wchartotest := #932; //Greek capital tau apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); //Test some symbols using the Unicode version wchartotest := #9829; //Heart suit apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); wchartotest := #9768; //White smilee apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); wchartotest := #9835; //Eighth note apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); //Test some invalid control code characters using the Unicode version wchartotest := #9; //Tab apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); wchartotest := #10; //Line feed apiretval := PathGetCharTypeW(wchartotest); newinfoline := 'PathGetCharTypeW called with ' + AnsiQuotedStr(wchartotest, '"') + ' returned : 0x' + IntToHex(apiretval, 8) + ' (' + IntToStr(apiretval) + ')'; Memo1.Lines.Add(newinfoline); Memo1.Lines.Add(''); END;
On one of our Windows Vista systems the above code produced the output shown below. However, when run on other systems and/or under other Windows versions the output may deviate significantly. Furthermore, because the application used to genertate the output only uses the ANSI character set, certain characters could not be depicted correctly.
PathGetCharType called with ":" returned : 0x00000008 (8) PathGetCharType called with "." returned : 0x00000003 (3) PathGetCharType called with "\" returned : 0x00000008 (8) PathGetCharType called with "/" returned : 0x00000000 (0) PathGetCharType called with "*" returned : 0x00000004 (4) PathGetCharType called with "?" returned : 0x00000004 (4) PathGetCharType called with "~" returned : 0x00000003 (3) PathGetCharType called with "A" returned : 0x00000003 (3) PathGetCharType called with "b" returned : 0x00000003 (3) PathGetCharType called with "C" returned : 0x00000003 (3) PathGetCharTypeW called with "S" returned : 0x00000003 (3) PathGetCharTypeW called with "s" returned : 0x00000003 (3) PathGetCharTypeW called with "?" returned : 0x00000003 (3) PathGetCharTypeW called with "?" returned : 0x00000003 (3) PathGetCharTypeW called with "?" returned : 0x00000003 (3) PathGetCharTypeW called with "?" returned : 0x00000003 (3) PathGetCharTypeW called with " " returned : 0x00000000 (0) PathGetCharTypeW called with "" returned : 0x00000000 (0)
Requirements
Unit: Declared and imported in (SST)ShlWAPI.pas
Library: (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj
Unicode: Implemented as ANSI (PathGetCharType and PathGetCharTypeA) and Unicode (PathGetCharTypeW) functions.
Min. ShlWAPI.dll version according to MS SDK doc.: 4.71
Min. ShlWAPI.dll version based on SST research: 4.71
Min. OS version(s) according to Microsoft SDK doc.: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0
Min. OS version(s) according to SST research.: Windows NT 4.0 with IE 4.0, Windows 95 with IE 4.0, Windows 98, Windows 2000 and later
See Also
IsCharSpace.
 
Windows APIs: PathGetCharType, IsCharSpace.


Document/Contents version 1.00
Page/URI last updated on 07.12.2023
 
Copyright © Stoelzel Software Technologie (SST) 2010 - 2015
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com